home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10635 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: in1.uu.net!interaccess!usenet
  2. From: brianmcg@interaccess.com (Brian V. McGroarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP. How to convert '0x12' into FF char?
  5. Date: 19 Mar 1996 02:10:18 GMT
  6. Organization: Internet Squire
  7. Message-ID: <4il52a$ma7@nntp.interaccess.com>
  8. References: <4iissm$s76@nntp.ucs.ubc.ca>
  9. Reply-To: brianmcg@interaccess.com
  10. NNTP-Posting-Host: d48-isdn.nhe.interaccess.com
  11. X-Newsreader: Internet Squire 1.20
  12.  
  13. Gordon Wong wrote:
  14.  
  15. >Let's say we have d='1' and e='2' and the following code segment:
  16. >:
  17. >:
  18. >f='0x';
  19. >strcpy(f,d);
  20. >strcpy(f,e);
  21. >
  22. >f now contains the string '0x12' right?
  23.  
  24. No -- you need to use strcat to append sections -- assuming that d and e
  25. were strings, you would have placed "2" into f.  I don't know of any
  26. character concatenation functions that are likely to come with your
  27. compiler, but one can be quickly written as something like:
  28.  
  29. void CatChar( char *inString, char addChar )
  30. {
  31.     inString[ strlen( inString ) + 1 ] = 0;
  32.     inString[ strlen( inString ) ] = addChar;
  33. }
  34.  
  35. ..make sure that inString is long enough to hold the extra character(s)
  36. though!
  37.  
  38.  
  39. >How would I write that out as a single ASCII FF character?
  40. >(d,e,f are char)
  41.  
  42. I don't believe I understand the question.  =^(  If you are wondering how
  43. to fetch the value of this, look at sscanf().  If you are looking to
  44. concatenate these all at once, C doesn't have built in operators to append
  45. the characters to each other into a string.
  46.  
  47.  
  48. ---
  49. Brian Valters McGroarty -- brianmcg@bix.com
  50. phone/fax (847) 439-7714
  51.